/**
 * 
 */
package org.bamboo.easyejb.demo.weather.ejb;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.bamboo.easyejb.base.BaseLocalSessionBean;
import org.bamboo.easyejb.demo.weather.model.CityNotFoundException;
import org.bamboo.easyejb.demo.weather.model.WeatherInfo;



/**
 * <p>
 * Title: GDIBOSS
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2005
 * </p>
 * <p>
 * Company: sunrise Tech Ltd.
 * </p>
 * 
 * @author Raymond KK He
 * @version 1.0
 */
public class WetherReportBean extends BaseLocalSessionBean implements WetherReport {	
	
	private static Map weatherInfoData = new HashMap(); 
	
	static {
		weatherInfoData.put("beijing", new WeatherInfo("Beijing",new Date(),"sunny",21) );
		weatherInfoData.put("new york", new WeatherInfo("New York",new Date(),"cloudy",12) );
		weatherInfoData.put("london", new WeatherInfo("London",new Date(),"cloudy",14) );
		weatherInfoData.put("guangzhou", new WeatherInfo("Guangzhou",new Date(),"sunny",30) );
		weatherInfoData.put("shanghai", new WeatherInfo("Shanghai",new Date(),"rainy",29) );
	}
	
	/**
	 * get today's weather info by city,  weather and temperature.
	 * @param city
	 * @return
	 * @throws Exception
	 */
	public WeatherInfo getWeatherInfo(String city)  throws CityNotFoundException {
		if(city == null)
			throw new CityNotFoundException(city);
		
		String city0 = city.toLowerCase();
		
		if(weatherInfoData.containsKey(city0))
			return (WeatherInfo) weatherInfoData.get(city0);
		else
			throw new CityNotFoundException(city);
	}
	
}
